package com.fenghongzhang.club_2303

import android.app.Application
import android.content.Intent
import android.os.Debug
import android.os.Trace
import android.util.Log
import cn.jiguang.api.utils.JCollectionAuth
import cn.jpush.android.api.JPushInterface


import com.alibaba.android.arouter.launcher.ARouter
import com.fenghongzhang.lib_utils.AppHolder
import com.tencent.mmkv.MMKV
import com.umeng.commonsdk.UMConfigure

import dagger.hilt.android.HiltAndroidApp

private const val TAG = "MyApp"
@HiltAndroidApp
class MyApp : Application(){
    override fun onCreate() {
        super.onCreate()

         // 这两行必须写在init之前，否则这些配置在init过程中将无效
        initARouter()
        //内存存储框架
        initMMKV()

        jPush()

        UMConfigure.init(this, "690030408560e34872d7a018", "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");


        AppHolder.initialize(this)



    }

    private fun jPush() {
        JPushInterface.setDebugMode(true)
        JPushInterface.init(this)
        Log.i(TAG, "onCreate: " + JPushInterface.ACTION_REGISTRATION_ID)

        val registrationID = JPushInterface.getRegistrationID(this)
        Log.i(TAG, "onCreate: $registrationID")
        JCollectionAuth.setAuth(this, true)
    }

    /**
     * ARouter初始化
     */
    private fun initARouter() {

        ARouter.openLog()
        ARouter.openDebug()
        ARouter.init(this)
    }

    /**
     * MMKV初始化
     */
    private fun initMMKV() {

        if (AppConfig.MMKV_ROOT_DIR_PATH.isEmpty()) {
            MMKV.initialize(this)
        } else {
            MMKV.initialize(this, AppConfig.MMKV_ROOT_DIR_PATH)
        }
    }

}